﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SC.GirdManage.Common;
using SC.GridManage.MN.API.Write.Application.Command.Artical;

namespace SC.GridManage.MN.API.Write.Controllers
{
    /// <summary>
    /// 文章控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ArticalController : ControllerBase
    {
        private readonly IMediator mediator;

        public ArticalController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 新建文章
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> CreateArtical(CreateArticalCommand request)
        {
            return mediator.Send(request);
        }       
        /// <summary>
        /// 删除(逻辑)文章
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<ApiResult<int>> DelArtical(DelArticalCommand request)
        {
            return mediator.Send(request);
        }        
        
        /// <summary>
        /// 更改文章
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<ApiResult<int>> UpdateArtical(UpdateAriticalCommand request)
        {
            return mediator.Send(request);
        }
    }
}